package com.yuncheng.spcyApi.constant.flow;

import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@Component(value = "YpltFlowConstant")
public class YpltFlowConstant implements FlowConstant {
    public final static String NODENAME = "任务受理,方案制作,查验方案审核,查验方案审批,现场检查,综合评定,科室复核,移送确认";

    public final static String NODENAME_SP = "任务受理,方案制作,查验方案审核,查验方案审批,现场检查,综合评定,科室复核,移送确认";

    public final static String HJMC_RWLR = "任务录入";
    public final static String HJMC_RWSL = "任务受理";
    public final static String HJMC_FAZZ = "方案制作";
    public final static String HJMC_FASH = "查验方案审核";
    public final static String HJMC_FASP = "查验方案审批";
    public final static String HJMC_XCJC = "现场检查";
    public final static String HJMC_JSSC = "技术审查";
    public final static String HJMC_ZHSC = "综合审查";
    public final static String HJMC_ZHPD = "综合评定";
    public final static String HJMC_KSFH = "科室复核";
    public final static String HJMC_YSQR = "移送确认";
    public final static String HJMC_JSSP = "技术审评";
    public final static String HJMC_SP_FASH = "审评方案审核";
    public final static String HJMC_SP_FASP = "审评方案审批";


    // 流程办理按钮类型 - 保存
    public final static String SUBMIT_TYPE_SAVE = "0";

    // 流程办理按钮类型 - 提交
    public final static String SUBMIT_TYPE_SUBMIT = "1";

    // 获取第一环节
    public  String getFirstNode(){
        String nodeNameList[] = NODENAME.split(",");
        return nodeNameList[0];
    }

    public  String getBlfs(String nodeName){
        return SpcyConstant.BLFS_DRJJ;
    }

    @Override
    public String getFywflcode() {
        return "001003";
    }

    @Override
    public String getFlowName() {
        return "药品流通-审评查验流程";
    }

    // 获取下环节名称
    public  String getNextNodeName(String nowNodeName){
        if (StringUtils.isNotBlank(nowNodeName) && nowNodeName.equals(HJMC_RWLR)){
            return HJMC_RWSL;
        }

        String nodeNameList[] = NODENAME.split(",");
        for (int i=0; i<nodeNameList.length; i++){
            if (nodeNameList[i].equals(nowNodeName)){
                if (i == nodeNameList.length-1){
                    return HJMC_LCJS;
                }else {
                    return nodeNameList[i+1];
                }
            }
        }
        return "";
    }

    // 获取上一个环节名称
    public String getPreviousName(String nowNodeName){
        String[] nodeNameList = NODENAME.split(",");

        for (int i=0; i<nodeNameList.length; i++){
            if (nodeNameList[i].equals(nowNodeName)){
                if (i==0){
                    return nodeNameList[i];
                }else {
                    int perviousI = i-1; // 上一个环节名称
                    return nodeNameList[perviousI];
                }
            }
        }
        return "";
    }

    // 获取审评下环节名称
    public String getSpNextNodeName(String nowNodeName){
        if (StringUtils.isNotBlank(nowNodeName) && nowNodeName.equals(HJMC_RWLR)){
            return HJMC_RWSL;
        }

        String nodeNameList[] = NODENAME_SP.split(",");
        for (int i=0; i<nodeNameList.length; i++){
            if (nodeNameList[i].equals(nowNodeName)){
                if (i == nodeNameList.length-1){
                    return HJMC_LCJS;
                }else {
                    return nodeNameList[i+1];
                }
            }
        }
        return "";
    }

    // 获取审评上环节名称
    public String getSpPreviousName(String nowNodeName){
        String[] nodeNameList = NODENAME_SP.split(",");

        for (int i=0; i<nodeNameList.length; i++){
            if (nodeNameList[i].equals(nowNodeName)){
                if (i==0){
                    return nodeNameList[i];
                }else {
                    int perviousI = i-1; // 上一个环节名称
                    return nodeNameList[perviousI];
                }
            }
        }
        return "";
    }
}
